﻿using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Text;
using System.Windows.Forms;
using RTCCore;

namespace LibGUI.MainForm.UserList
{
    public class BaseUserNode : TreeNode
    {
        protected string _userName;
        protected string _userURI;

        protected RTC_PRESENCE_STATUS _userStatus = RTC_PRESENCE_STATUS.RTCXS_PRESENCE_OFFLINE;

        /// <summary>
        /// UserName attribute
        /// </summary>
        public string UserName
        {
            get
            {
                return _userName;
            }
        }

        /// <summary>
        /// UserURI attribute
        /// </summary>
        public string UserURI
        {
            get
            {
                return _userURI;
            }
        }

        /// <summary>
        /// UserStatus attribute
        /// </summary>
        public RTC_PRESENCE_STATUS UserStatus
        {
            get
            {
                return _userStatus;
            }

            set
            {
                _userStatus = value;
            }
        }

        /// <summary>
        /// Constructor, do some initialization work
        /// </summary>
        public BaseUserNode() {
            
        }

        public override int GetHashCode()
        {
            return (base.GetHashCode() ^ _userURI.GetHashCode());
        }

        public override bool Equals(object obj)
        {
            Debug.Assert(null != obj);
            Debug.Assert(obj is BaseUserNode);

            if(!(obj is BaseUserNode)) {
                return false;
            }

            BaseUserNode userNode = (BaseUserNode) obj;
            Debug.Assert(null != userNode);

            return userNode._userURI.Equals(this._userURI);
        }

        public override string ToString()
        {
            StringBuilder builder = new StringBuilder();

            builder.AppendFormat("UserName = {}, UserURI = {}, UserStatus = {}",UserName,UserURI,UserStatus);

            return builder.ToString();
        }
    }
}
